﻿using System.Collections.Generic;
using IQIGame.Onigao.Framework;
using IQIGame.Onigao.Game;
using LFloatMath.Math;

namespace IQIGame.Onigao.Logic
{
    public class TargetSelect_All : TargetSelect
    {
        public override ETargetSelectType selectType => ETargetSelectType.All;
        public override bool selectByUnit => true;
        
        public override void TrySelect(SelectParam rData, LVector2 rSelfPos, ref List<Unit> rTargets)
        {
            List<Unit> rAllUnits = ListPool<Unit>.Get();
            TargetSelectUtil.GetAllTargetsByRelation(this.self, this.targetRelation, ref rAllUnits);

            if (rAllUnits != null)
            {
                rTargets.AddRange(rAllUnits);
            }

            ListPool<Unit>.Put(rAllUnits);
        }

        public override void Free()
        {
            ClassPool.Put(this);
        }
    }
}